//
//  LcPersistenceCenter.h
//  18Birdies
//
//  Created by Lc on 15/3/23.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import "LcSingleton.h"

@class LcPersistenceMeta;

@interface LcPersistenceCenter : LcSingleton

@property(nonatomic, copy, readonly) NSString* rootDirectory;
@property(nonatomic, assign, readonly) BOOL outOfFreeDiskSpace;

// called in AppDelegate
- (void)updateFreeDiskSpace;

- (id)objectForPersistenceMeta:(LcPersistenceMeta*)persistenceMeta;
- (void)saveObject:(id)value
forPersistenceMeta:(LcPersistenceMeta*)persistenceMeta;
- (void)remove:(LcPersistenceMeta*)persistenceMeta;

- (void)saveData:(NSData*)data toFile:(NSString*)fileName;
- (NSData*)loadDataFromFile:(NSString*)fileName;
- (void)removeFile:(NSString*)fileName;

- (void)saveData:(NSData*)data
          toFile:(NSString*)fileName
     compressing:(BOOL)compressing
      encrypting:(BOOL)encrypting;
- (NSData*)loadDataFromFile:(NSString*)fileName
                compressing:(BOOL)compressing
                 encrypting:(BOOL)encrypting;

// only for communicate with server
- (NSData*)compressGzip:(NSData*)data;
- (NSData*)uncompressGzip:(NSData*)data;

// non recursive
- (NSArray*)fileNamesInFolder:(NSString*)folerName;

- (BOOL)fileExists:(NSString*)fileName;

- (void)moveUrl:(NSURL*)url toFile:(NSString*)relativePath;
- (void)moveFile:(NSString*)srcRelativePath toFile:(NSString*)destRelativePath;

@end
